package com.loyi.ams.gateway.hbmis.dao;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.loyi.cloud.hbmis.domain.HourData;

@Mapper
public interface IDayDataDAO {
	@Select("SELECT * FROM t_bas_data_day WHERE datatime=#{datatime} AND ptid=#{ptid} AND pollcode=#{pollcode} LIMIT 0,1")
	public HourData find(@Param("datatime") long datatime, @Param("ptid") String ptid,
			@Param("pollcode") String pollcode);

	@Update("UPDATE t_bas_data_day SET value=#{data.value} WHERE datatime=#{datatime} AND ptid=#{ptid} AND pollcode=#{pollcode} ")
	public void update(@Param("datatime") long datatime, @Param("ptid") String ptid, @Param("pollcode") String pollcode,
			@Param("data") HourData data);

	@Insert("INSERT INTO t_bas_data_day(datatime,uploadtime,ptid,deviceid,channelid,pollcode,value,maxval,minval,protocol) VALUES (#{data.datatime},#{data.uploadtime},#{data.ptid},#{data.deviceid},#{data.channelid},#{data.pollcode},#{data.value},#{data.maxValue},#{data.minValue},#{data.protocol})")
	public void insert(@Param("data") HourData data);
}
